package web

import (
	"ksd-social-api/commons/base/controller"
	"ksd-social-api/modules/special/model/context"
)

/**
 * 用户点赞
 * @author feige
 * @date 2023-11-23
 * @version 1.0
 * @desc
 */
type SpecialUserLikeController struct {
	controller.BaseController
}

/**
 * 点赞用户
 * @author feige
 * @date 2023-10-10
 * @version 1.0
 */
func (web *SpecialUserLikeController) SaveCancelSpecialUserLike() {
	favLikeContext := context.FavLikeContext{}
	web.BindJSON(&favLikeContext)
	// 登录用户---点赞用户
	favLikeContext.UserId = web.GetUserId()
	favLikeContext.Avatar = web.GetUserAvatar()
	favLikeContext.Uuid = web.GetUuid()
	favLikeContext.Nickname = web.GetUserNickname()
	favLikeContext.Username = web.GetUsername()
	favLikeContext.SystemId = web.GetSystemId()
	favLikeContext.SystemName = web.GetSystemName()
	// 点赞，取消 和 再点赞
	focus := specialUserLikeService.SaveSpecialUserLike(favLikeContext)
	web.Ok(focus)
}

/**
 * 删除点赞
 * @author feige
 * @date 2023-10-10
 * @version 1.0
 */
func (web *SpecialUserLikeController) DelSpecialUserLike() {
	userFocusDelContext := context.FavLikeDelContext{}
	web.BindJSON(&userFocusDelContext)
	userFocusDelContext.UserId = web.GetUserId()
	userFocusDelContext.SystemId = web.GetSystemId()
	focus := specialUserLikeService.DelUserLike(userFocusDelContext)
	if !focus {
		web.FailCodeMsg(1001, "删除点赞失败!")
		return
	}
	web.Ok(focus)
}
